package com.scj.vue3springboot.controller.sys;

import com.scj.vue3springboot.entity.SysMenu;
import com.scj.vue3springboot.entity.SysRole;
import com.scj.vue3springboot.entity.SysUser;
import com.scj.vue3springboot.service.SysMenuService;
import com.scj.vue3springboot.util.Result;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author ShiChaojie
 * @date 2023/10/17 14:12
 */
@Slf4j
@RestController
@RequestMapping("/menu")
public class MenuController {

    @Autowired
    private SysMenuService sysMenuService;

    @ApiOperation("获取所有菜单信息接口")
    @GetMapping("/findAllMenu")
    public Result findAllMenu() {
        return sysMenuService.findAllMenu();
    }

    @ApiOperation("添加菜单接口")
    @PostMapping("/addMenu")
    public Result addMenu(@RequestBody SysMenu sysMenu, @RequestHeader("token") String token) {
        return sysMenuService.addMenu(sysMenu,token);
    }

    @ApiOperation("修改菜单接口")
    @PutMapping("/updateMenu")
    public Result updateMenu(@RequestBody SysMenu sysMenu, @RequestHeader("token") String token) {
        return sysMenuService.updateMenu(sysMenu,token);
    }

    @ApiOperation("删除菜单接口")
    @DeleteMapping("/deleteMenu/{menuId}")
    public Result deleteMenu(@PathVariable Long menuId,@RequestHeader("token") String token) {
        return sysMenuService.deleteMenu(menuId,token);
    }
}
